<?
class ECLib
{
    static $check_uri = false;

    static function get_config($delcache = false) {
        if (!CGlobal::$configs || $delcache) {
            if (ArrCache::is_not_cached('config_arr', 0, '', $delcache)) {
                if (!$delcache) {
                    $re = DB::query('SELECT * FROM config', __LINE__ . __FILE__);

                    if ($re) {
                        while ($value = mysql_fetch_assoc($re)) {
                            CGlobal::$configs[$value['cf_name']] = $value;
                        }
                    }

                    ArrCache::set(CGlobal::$configs);
                }
            } 
            else
            {
                CGlobal::$configs = ArrCache::$arr_cache;
                ArrCache::$arr_cache = array();
            }
        }
    }

    static function get_cities($delcache = false)
    {
        if(ArrCache::is_not_cached('city_arr',0,'',$delcache))
        {
			if(!$delcache)
			{
				//added for All Cities
				CGlobal::$all_cities[0] = array(
												"id" 	 => 0,
												"name" 	 => "Toàn quốc",
												"root" 	 => 1,
												"rbname" => "Toan-quoc",
												"id_citiesfather"=>0
												);
												
				$sql_str = "SELECT id, name, root, status, id_citiesfather, id_area, orders, active FROM ".TABLE_PREFIX."cities WHERE active=1 ORDER by name ASC";
				$result  = DB::query($sql_str);
				
				$aryDistricts = array();
				
				while($city = mysql_fetch_assoc($result))
				{
					$city["rbname"] = ECLib::safe_title($city["name"]);
				
					CGlobal::$all_cities[$city['id']] 			= $city;
					CGlobal::$cities_name[strtolower($city['rbname'])] 			= $city;
					CGlobal::$cities_list [$city['id_area']][] 	= $city;
					
					//add for districts
					if($city['id_citiesfather'] > 0)
					{
						$aryDistricts['id'] = $city['id'];
						$aryDistricts['name'] = $city['name'];
						$aryDistricts['id_citiesfather'] = $city['id_citiesfather'];
						$aryDistricts['rbname'] = $city["rbname"];
						
						CGlobal::$all_districs[$city['id_citiesfather']][$city['id']] 			= $aryDistricts;
					}
				}
				
				$sql_str = "SELECT * FROM ".TABLE_PREFIX."area ORDER by orders ASC,atitle ASC";
				$result  = DB::query($sql_str);
				
				while($area = mysql_fetch_array($result)){
					CGlobal::$city_areas[$area['aid']] = $area;
				}
	
				ArrCache::set(array('array_city'=>CGlobal::$all_cities,'array_districs'=>CGlobal::$all_districs,'cities_list'=>CGlobal::$cities_list,'city_areas'=>CGlobal::$city_areas,'city_name'=>CGlobal::$cities_name));
			}
			else{				
				foreach (CGlobal::$my_server as $server){//Tạo lại file js cho city
					@fopen("http://$server/citygen.php","r");
				}				
			}
		}
		else{
			$city_arr	 			= ArrCache::get();
			
			CGlobal::$all_cities  	= $city_arr['array_city'];
			CGlobal::$cities_list 	= $city_arr['cities_list'];
			CGlobal::$city_areas 	= $city_arr['city_areas'];
			CGlobal::$all_districs 	= $city_arr['array_districs'];
			CGlobal::$cities_name 	= $city_arr['city_name'];
		}
    }

    /* ------------------------------------------------------------------------- */
    // Sets a cookie, abstract layer allows us to do some checking, etc
    /* ------------------------------------------------------------------------- */
    static function my_setcookie($name, $value = '', $expires = 0, $set_type = 1)
    {
        $expires = ($expires) ? $expires : TIME_NOW + 60 * 60 * 24 * 365;

        if (WEB_DOMAIN != 'localhost' && strpos($_SERVER['HTTP_HOST'], WEB_DOMAIN) !== false && $set_type == 1)
        {
            setcookie($name, $value, $expires, "/", '.' . WEB_DOMAIN);
        }
        else
        {
            setcookie($name, $value, $expires, WEB_ROOT);
        }
        
        $_COOKIE[$name] = $value;
    }

    static function subString($str, $start, $num, $ext=false) {
        $str = ECLib::plainText($str);

        if ($num > strlen($str) - $start)
            $num = strlen($str) - $start;

        if ($num <= 0)
            return '';

        $pos = strpos(substr($str, $start + $num + 1, strlen($str) - $start - $num - 1), ' ');

        $st = substr($str, $start, $num + $pos + 1);

        if ($ext && strlen($str) - $start > $num)
            $st.='..';

        return $st;
    }

    static function strippedLink($str, $length=68) {
        if ((strlen($str) - $length ) < 3) {
            return $str;
        }
        return substr($str, 0, floor(($length - 3) / 2)) . '...' . substr($str, -floor(($length - 3) / 2));
    }

    // ham tao descprtion trong tag DESCRIPTION
    static function descriptionText($str) {
        $meta_desc = ECLib::post_db_parse_html($str);
        $meta_desc = ECLib::plainText(html_entity_decode($meta_desc, ENT_QUOTES, "UTF-8"));
        $meta_desc = str_replace('\'', '', $meta_desc);
        $meta_desc = str_replace('"', '', $meta_desc);
        return String::delDoubleSpace(String::trimSpace($meta_desc));
    }

    static function plainText($str) {
        $arr_replace = array(
            '/\<p (.+?)\>(.+?)\<\/p\>/is' => '$2' . ' ',
            '/\<br \/\>/is' => ' ',
            '/\<br\>/is' => ' '
        );

        $str = preg_replace(array_keys($arr_replace), $arr_replace, $str);
        $str = strip_tags($str);

        //$filter = "\$|,,|@|\!|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\$|\.";
        //$filter = "\$|,,|@|\!|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\$|\.\.";
        //$str = preg_replace("/$filter/is", " ", $str);

        return self::delDoubleSpace(self::trimSpace(str_replace(array(chr(13), chr(9), chr(10), chr(239)), " ", $str)));
    }

    static function getImageThumb($imagePath, $width=0, $height=0, $limit_size=0, $server_no=0) {
        if ($width && $height)
            return 'http://' . CGlobal::$img_server[$server_no] . "thumb/{$width}_$height/$imagePath";
        elseif ($width) {
            if ($limit_size)
                return 'http://' . CGlobal::$img_server[$server_no] . "thumb_wl/{$width}/$imagePath";
            else
                return 'http://' . CGlobal::$img_server[$server_no] . "thumb_w/{$width}/$imagePath";
        }
    }

    static function getImageThumbIn($imagePath, $width, $height, $server_no=0) {
        return 'http://' . CGlobal::$img_server[$server_no] . "thumb_in/{$width}_$height/$imagePath";
    }

    static function base64_url_encode($input) {
        return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
    }

    static function getImageThumbMax($imagePath, $title='', $full_with_domain=true, $server_no=0) {
        if ($title != '') {
            $title = ($title ? ECLib::base64_url_encode(str_replace(array('"', "'"), array('&quot;', '\\\''), stripslashes($title))) : '');
            $file_ext = Upload::getExtension($imagePath);
            $imagePath = dirname($imagePath) . '/' . basename($imagePath, $file_ext) . ',' . $title . $file_ext;
        }
        //return ($full_with_domain?'http://'.IMAGE_PATH:'')."thumb_max/1200_800/$imagePath";
        return ($full_with_domain ? 'http://' . CGlobal::$img_server[$server_no] : '') . "thumb_max/$imagePath";
    }

    static function CheckDir($pDir, $check_memcache = false) {
        if (!$check_memcache) {
            if (is_dir($pDir))
                return true;
            if (!@mkdir($pDir, 0777, true)) {
                return false;
            }
            self::chmod_dir($pDir, 0777);
        }
        return true;
    }

    static function chmod_dir($dir, $mod=0777) {
        $parent_dir = dirname(str_replace(ROOT_PATH, '', $dir));
        if ($parent_dir != '' && $parent_dir != '.') {
            //echo $parent_dir.'/<br />';
            @chmod($dir, $mod);
            self::chmod_dir($parent_dir, $mod);
        }
        return true;
    }

    static function get_yahoo_avatar($yahoo_id, $user_id=0, $server_no = 0) {
        $cache_path = ROOT_PATH . '_cache/avatar/';
        $up_file = TIME_NOW . '_' . $yahoo_id . '.gif';

        $up_path = self::folderUpload($user_id, 'avatar');

        if (self::checkDir($cache_path)) {
            @file_put_contents($cache_path . $up_file, @file_get_contents('http://img.msg.yahoo.com/avatar.php?yids=' . $yahoo_id . '&format=gif'));
            if (file_exists($cache_path . $up_file)) {
                if (self::ftp_image_connect($server_no)) {
                    self::ftp_check_dir($up_path, true, $server_no);

                    if (self::ftp_image_put_file($up_path . $up_file, $cache_path . $up_file, $server_no)) {
                        @unlink($cache_path . $up_file);
                        self::ftp_image_close();
                        return $up_path . $up_file;
                    } else {
                        return 'Could not ftp file: ' . $up_path . $up_file . ', ' . $cache_path . $up_file . ', ' . $server_no;
                    }
                    self::ftp_image_close();
                } else {
                    return 'Could not connect to image server: ' . $server_no;
                }
                @unlink($cache_path . $up_file);
            } else {
                return 'Could not create cache file: ' . $cache_path . $up_file;
            }
        }
        return 'Cache path not exist: ' . $cache_path;
    }
   

    static function show_error_mes($mess="") {
        //Url::access_denied();
        global $display;

        $display->add('content', $mess);
        $display->output('error', false, 'Error');
    }

    static function reload_captcha() {
        $alphanum = "abcdefghiklmopqrstuvwxyz0123456789";
        $new_string = substr(str_shuffle($alphanum), 0, 3);
        $_SESSION["ecore_validate"] = $new_string;
    }

    //get real IP - by TuanNV - 26/09/08
    static function ip_first($ips) {
        if (($pos = strpos($ips, ',')) != false) {
            return substr($ips, 0, $pos);
        } else {
            return $ips;
        }
    }

    static function ip_valid($ips)
    {
        if (isset($ips)) {
            $ip = self::ip_first($ips);
            $ipnum = ip2long($ip);
            if ($ipnum !== -1 && $ipnum !== false && (long2ip($ipnum) === $ip)) { // PHP 4 and PHP 5
                if (($ipnum < 167772160 || $ipnum > 184549375) && // Not in 10.0.0.0/8
                        ($ipnum < -1408237568 || $ipnum > -1407188993) && // Not in 172.16.0.0/12
                        ($ipnum < -1062731776 || $ipnum > -1062666241))   // Not in 192.168.0.0/16
                    return true;
            }
        }
        return false;
    }

    static function ip() {
        $check = array('HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED',
            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED',
            'HTTP_VIA', 'HTTP_X_COMING_FROM', 'HTTP_COMING_FROM');

        foreach ($check as $c) {
            //if (self::ip_valid(&$_SERVER[$c])) {
            if (self::ip_valid(@$_SERVER[$c])) {
                return self::ip_first(@$_SERVER[$c]);
            }
        }

        return $_SERVER['REMOTE_ADDR'];
    }

    function convertCurrency($price, $currency_id) {
        if ($currency_id == 2) {
            $price = $price * CURRENCY_USD;
        } elseif ($currency_id == 3) {
            $price = $price * CURRENCY_EUR;
        }
        return $price;
    }

    function is_mobile($value) {

        $arr_service = array('091', '090', '093', '094', '098', '099', '096', '092', '097', '095', '016', '012', '019');

        if ($value == "") {
            return false;
        }

        if (substr($value, 0, 1) != "0") {
            return false;
        }

        if (!in_array(substr($value, 0, 3), $arr_service)) {
            return false;
        }
        return true;
    }

    static function check_uri()
    {
        if (!self::$check_uri) {
            CGlobal::$request_uri = $_SERVER['REQUEST_URI'];
            if (isset($_SERVER['HTTP_REFERER'])) {
                CGlobal::$referer_url = $_SERVER['HTTP_REFERER'];
            }

            CGlobal::$query_string = $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
            $dir = (dirname($_SERVER['SCRIPT_NAME']) ? dirname($_SERVER['SCRIPT_NAME']) : '');

            $dir = str_replace('\\', '/', $dir);

            if ($dir && $dir != '/' && $dir != './') {
                if ($dir[0] != '/') {
                    $dir = '/' . $dir;
                }
                $dir.=$dir[strlen($dir) - 1] != '/' ? '/' : '';
                CGlobal::$query_string = str_replace($dir, '', CGlobal::$request_uri);
            } else {
                $uri = CGlobal::$request_uri;
                if (strlen($uri) > 1) {

                    while ($uri[0] == '/') {
                        $uri = substr($uri, 1, strlen($uri) - 1);
                    }

                    CGlobal::$query_string = $uri;
                    unset($uri);
                } else {
                    CGlobal::$query_string = '';
                }
            }

            self::$check_uri = true;
        }
    }

    static function genUniqueFileName($str = '') {
        $str = explode('.', $str);
        $str = array_pop($str);
        $mini = microtime(true);
        return $mini . '.' . $str;
    }

    static function sortByLength($a, $b) {
        return strlen($b) - strlen($a);
    }

    static function HighLightKeyword($string, $keywords, $limit=0, $style="font-weight:bold;", $emphasis='...') {
        $arrKeywords = explode(',', $keywords);
        $highlighted = '';
        usort($arrKeywords, "EnbacLib::sortByLength"); // Sắp xếp giảm dần theo số ký tự, đảm bảo không highlight 1 keyword ít ký tự nhiều lần

        if ($limit) {
            $arrWords = explode(' ', $string);

            $wordCount = count($arrWords);

            if ($wordCount > $limit) { // Cắt xâu có bao gồm keyword, nếu có $limit
                $start = 0;
                $len = $limit;

                for ($i = 0; $i < $wordCount; $i++) {
                    if (stripos($arrWords[$i], $arrKeywords[0]) !== false) {
                        if (($i - 5) > 0)
                            $start = $i - 5; // lấy 5 word trước khi keyword xuất hiện
 if (($wordCount - $start) < $limit) { // Số lượng word lấy ra ít hơn $limit truyền vào
                            //Dịch offset start lùi về trước, tính từ cuối xâu
                            $start = $wordCount - $limit;
                        }
                        break;
                    }
                }
                if ($len)
                    $string = ($start ? $emphasis : '') . implode(' ', array_slice($arrWords, $start, $len)) . (($start + $limit < $wordCount) ? $emphasis : '');
            }
        }

        foreach ($arrKeywords as $keyword) {
            if (!$highlighted || ($highlighted && (stripos($highlighted, $keyword) === false))) { // Keyword chưa được highlight
                //$string = preg_replace("/\b($keyword)\b/i", '<span style="' . $style . '">\1</span>', $string);
                $string = str_ireplace($keyword, '<span style="' . $style . '">' . $keyword . '</span>', $string);
                $highlighted .= ( $highlighted ? ',' : '') . $highlighted;
            }
        }
        return $string;
    }
    
    static function is_search_engine()
    {
    	static $is_search_engine = false;
    	
    	if($is_search_engine === false)
    	{
    		$is_search_engine = 0; 
    		
			/*
			$is_search_engine_array = array("Google", "Fast", "Slurp", "Ink", "Atomz", "Scooter", "Crawler", "MSNbot", "Poodle", "Genius"); 
			
			foreach($is_search_engine_array as $key => $val)
			{
				if(strstr($_SERVER['HTTP_USER_AGENT'], $val))
				{
					$is_search_engine = 1;
					break;
				}
			}
			*/
			
			$is_search_engine_array = array("Google","Yahoo","Fast", "Slurp", "Ink", "Atomz", "Scooter", "Crawler", "MSNbot", "Poodle", "Genius"); 
			
			$SearchEngineList 		=  join('|',$is_search_engine_array);
			
			if(preg_match("/($SearchEngineList)/is",$_SERVER['HTTP_USER_AGENT']))
			{
				$is_search_engine 	= 1;		
			}
		}
		
		return $is_search_engine;
    }
    
	//Hàm chuẩn hóa tags
	static function unique_tags($tags,$standard_tags = array()) {
		$tags_return = array();
		$tags_tmp   = array();
		$standard_tags = array();
		
		if(!is_array($standard_tags) && $standard_tags!=''){
			if($standard_tags!=''){
				$standard_tags = explode(',', $standard_tags);
				$standard_tags = array_map('trim', $standard_tags);
			}
			else{
				$standard_tags   = array();
			}
		}
		$tags_u = array_map('ECLib::convert_unicode_to_lowercase', $standard_tags);
		
		foreach ($tags as $key => $tag){
			if(!in_array(ECLib::convert_unicode_to_lowercase($tag), $tags_tmp)){//Tag chưa có trong mảng trả về
				if($standard_tags){
					$key = array_search(ECLib::convert_unicode_to_lowercase($tag), $tags_u);
					
					if($key === false){
						$tags_return[] 	= $tag;
						$tags_tmp[] 	= ECLib::convert_unicode_to_lowercase($tag);
					}
					else{
						$tags_return[] 	= $standard_tags[$key];
						$tags_tmp[] 	= ECLib::convert_unicode_to_lowercase($standard_tags[$key]);
					}
				}
				else{
					$tags_return[] 	= $tag;
					$tags_tmp[] 	= ECLib::convert_unicode_to_lowercase($tag);
				}
			}
		}
		
		return $tags_return;
	}
	
	static function sphinx_getParam($searchword) {
		$searchword = str_replace('"','',$searchword);
		$searchword = str_replace("'","",$searchword);
		$searchword = str_replace("*","",$searchword);
		$searchword = str_replace("script","",$searchword);
		$searchword = preg_replace("/\s+/", " ", $searchword);
		return $searchword;
	}
	
	static function fillter_img($src){
	 //echo $img;
	 //$img = stripcslashes($img);
	  if($src = String::trimSpace($src)){
	  
	  
	   return "<img src='".$src."'>";
	  }
	 
	  return '';
	}
	
	
	static function tags_filter($text, $tags = '', $replace = false,$return_tags = false){
		//Check for banned words. If a banned word appear, raise warning
		//Code by Nova 02.07.08
		//Load configs
		
		/*	
		ALTER TABLE `phpclass_ad` ADD `ad_tags` VARCHAR( 255 ) NOT NULL AFTER `ad_description` ;
		INSERT INTO `phpclass_config` (`cf_id`, `cf_name`, `cf_value`) VALUES (3, 'tags', 'gai goi,viet minh,cu ho chi minh');	
		*/
		//error_reporting(E_ALL);
	
		//Neu ko truyen cat_tags	
		
		if(!$tags){
			ECLib::get_config();
			$tags		= CGlobal::$config['tags'];
		}
		
		$text = String::trimSpace(strip_tags($text));
			
		//explode to array
		$f = explode(',', $tags);
		$f = array_map('trim', $f);
		$f = array_map('ECLib::remove_special_sybol', $f);
		//implode to string with | (OR) to try to match the patterns badwords //// and clear free |
		
		$tags_arr = array();
		
		if($f)
		{
			$arr = array();
			
			foreach ($f as $value)
			{
			
				$arr[] = $value;
				
				if(count($arr) == 50)
				{
					$filtro = String::delDoubleSpace(String::trimSpace(str_replace('||','|',implode('|', $arr))));
					
					preg_match_all("/($filtro)/uis",$text,$matches);	
					//overwrite $tags
					
					if($matches[0])
					{
						$tags_arr = array_unique(array_merge($tags_arr, $matches[0]));
					}
					
					$arr = array();
				}
			}
		}
		
		
		if($return_tags){
			return $tags_arr;
		}
		else
		{
			$tags = "";
			foreach($tags_arr as $value)//foreach($matches[0] as $value)
		    {
		   	 	$tags .= $value.',';
		    }
			
	    	return  substr_replace($tags, '', -1);
		}
	}
	
	function filter_link($link,$text){
	  if($text = String::trimSpace($text)){
		$text = ECLib::strippedLink(ECLib::plainText($text));
		if(strpos($link,'http://' . WEB_DOMAIN)===0 || strpos($link,'http://www.' . WEB_DOMAIN)===0 || strpos($link,'http://' . WEB_DOMAIN)===0 || strpos($link,'http://www.' . WEB_DOMAIN)===0 || strpos($link,'http://')===false){
			return "<a href=\"$link\" target=\"_blank\">$text</a>";
		}
	   	return "<a href=\"$link\" rel=\"nofollow\" target=\"_blank\">$text</a>";
	  }
	  return '';
	}
	
	function filter_link2($link)
	{
        $elink = '';
        if(strpos($link,WEB_ROOT) === false && (strpos($link,'http://') !== false || strpos($link,'https://') !== false || strpos($link,'ftp://') !== false)){
            $link = WEB_ROOT.'external_link.html?url='.$link;
            $elink = 'elink';
        }

		return "<a class=\"$elink\" href=\"$link\" rel=\"nofollow\" target=\"_blank\">";
	}
	
	static function generatePassword($len=5)
	{
		$al = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
		
		$date = date("Hs");
		$password = "$date";
				
		for ($index = 1; $index <= $len; $index++) 
		{
				$randomNumber = rand(1,strlen($al));
				$password .= substr($al,$randomNumber-1,1);
		}
	
		return $password;
	}

	static function validEmail($aEmail){
		//$aEmail=ereg_replace("_","",$aEmail);	
		$aEmail=str_replace("_","",$aEmail);	
		if(preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,4}$/",$aEmail, $regs))
	  		return true;
		else
			return false;
	}
	
	static function check_mobile($mobile)
	{
		$mobile 			= str_replace(array(' ','.',',','+'), '', $mobile);
	
		$listValidPhone = array('09','012','016','0188','0199','849','8412','8416','84188','84199');//Các đầu số check
		
		$isNum  		= false;
		
		foreach($listValidPhone as $v)
		{
			$checkNum 	= substr($mobile ,0 , strlen($v));
			
			if(in_array($checkNum,$listValidPhone))
			{
				if(strpos($mobile,'0')  === 0)
				{
					$mobile = "84".substr($mobile,1);
				}
				
				if((strpos($mobile,'849')  === 0 && strlen($mobile) == 11) || (strpos($mobile,'841')  === 0 && strlen($mobile) == 12)){
					return $mobile;
				}
				return '';
			}
		}
		
		return '';
	}

    static function mouse_hover($color='#EAF1FB', $return=false) {
        $str = ' onmouseover="tr_color=this.style.backgroundColor;this.style.backgroundColor=\'' . $color . '\'" onmouseout="if(typeof(tr_color)!=\'undefined\'){this.style.backgroundColor=tr_color;}" ';
        if ($return

            )return $str;else
            echo $str;
    }
	
    //Xóa tất cả các file, thư mục bên trong 1 thư mục
	static function empty_dir($name, $remove_self = false)
	{
		if(is_dir($name))
		{
			if($dir = opendir($name))
			{
				$dirs = array();
				
				while($file=readdir($dir))
				{
					if($file!='..' and $file!='.')
					{
						if(is_dir($name.'/'.$file))
						{
							$dirs[]=$file;
						}
						else
						{
							@unlink($name.'/'.$file);
						}
					}
				}
				
				closedir($dir);
				
				foreach($dirs as $dir_)
				{
					self::remove_dir($name.'/'.$dir_);
				}
				
				if($remove_self)
				{
					@rmdir($name);
				}
			}		
		}
	}
	
	//Xóa tất cả các file, thư mục bên trong 1 thư mục và cả thư mục hiện tại
	static function remove_dir($name)
	{
		if(is_dir($name))
		{
			if($dir = opendir($name))
			{
				$dirs = array();
				
				while($file=readdir($dir))
				{
					if($file!='..' and $file!='.')
					{
						if(is_dir($name.'/'.$file))
						{
							$dirs[]=$file;
						}
						else
						{
							@unlink($name.'/'.$file);
						}
					}
				}
				
				closedir($dir);
				
				foreach($dirs as $dir_)
				{
					self::remove_dir($name.'/'.$dir_);
				}
				
				@rmdir($name);
			}		
		}
	}

    static function dump($a){
        echo '<pre>';
        var_dump($a);
        echo '</pre>';
    }

    static function print_r($a){
        echo '<pre>';
        print_r($a);
        echo '</pre>';
    }
}
?>